package com.samoilovich.belarustoday.mainscreen.fragments;

import android.content.pm.PackageInfo;
import android.os.Bundle;
import android.text.Html;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.samoilovich.belarustoday.R;
import com.samoilovich.belarustoday.basefragments.BaseFragment;
import com.samoilovich.belarustoday.tools.Utility;

public class InfoFragment extends BaseFragment {
	private final String TAG = getClass().getName();
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		mRootView = inflater.inflate(R.layout.fragment_info, null);
        mHideOptionsMenu = true;
		prepareActionBarViews(R.string.empty_str, R.string.options_label, true);
		prepareVersion();

		return mRootView;
	}

    // -----------------------------------------------------------------------------------
	private void prepareVersion() {
		PackageInfo info;
		TextView versionLabel = (TextView) mRootView.findViewById(R.id.textView_version);
		String infoStr = getResources().getString(R.string.version_label);
		
		try {
			info = getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0);
			versionLabel.setText(Html.fromHtml(String.format(infoStr, info.versionName)));
		} catch (Exception exp) {
			Log.e(TAG, exp.toString());
			exp.printStackTrace();
		}
	}
	
}